import matplotlib
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab
import matplotlib.cbook as cbook

from class_test import *

def plot(x, y, values, xmax, ymax):
    fig = plt.figure()
    ax = fig.add_subplot(111)
    #ax.scatter(delta1[:-1], delta1[1:], c=close, s=volume, alpha=0.75)
    #ax.scatter(delta1[:-1], delta1[1:], c='y', s=volume, alpha=0.75)
    ax.scatter(x, y, c=values, s=values, alpha=0.75)
    
    
    plt.xlim(0, xmax)
    plt.ylim(0, ymax)

    ax.set_xlabel(r'X', fontsize=20)
    ax.set_ylabel(r'Y', fontsize=20)
    ax.set_title('Gene Expression (z = 42)')
    ax.grid(True)

    plt.show()


x = [ 60, 61, 62, 63, 64, 65,  4,  5,  6,  7,  8,  9 ]
y = [ 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16 ]
#v = [ 0.635426, 0.176489, 0.0989954, 0.182815, 0.107727, 0.0470556, 0.0147637, 0.0120235, 0.0174842, 0.0247749, 0.0759618, 1.11105 ]
v = [ 60.635426, 55.176489, 50.0989954, 45.182815, 40.107727, 35.0470556, 30.0147637, 25.0120235, 20.0174842, 15.0247749, 10.0759618, 5.11105 ]
#print 'x', x
#print 'y', y
#print 'v', v

data = ThreeDData()

# unpickle arrays
data.x = load_array('3dDataX.pkl')
data.y = load_array('3dDataY.pkl')
data.z = load_array('3dDataZ.pkl')
data.value = load_array('3dDataValue.pkl')

#print data.x
#print data.y
#print data.z
#print data.value
print data.size()
print data.check_size()
trimmed_data = trim(data, 0.75)
print 'trimmed_data:\n', trimmed_data.to_string()

sliced_data = slice(trimmed_data, 42) 
print 'sliced_data:\n', sliced_data.to_string()

'''
#delta1 = np.diff(r.adj_close)/r.adj_close[:-1]

# size in points ^2unicode_minus
#volume = (15*r.volume[:-2]/r.volume[0])**2
#close = 0.003*r.close[:-2]/0.003*r.open[:-2]

fig = plt.figure()
ax = fig.add_subplot(111)
#ax.scatter(delta1[:-1], delta1[1:], c=close, s=volume, alpha=0.75)
#ax.scatter(delta1[:-1], delta1[1:], c='y', s=volume, alpha=0.75)
ax.scatter(x, y, c=v, s=v, alpha=0.75)

ax.set_xlabel(r'X', fontsize=20)
ax.set_ylabel(r'Y', fontsize=20)
ax.set_title('Gene Expression (z = 36)')
ax.grid(True)

plt.show()
'''

#plot(x, y, v)
xmax = int((float(data.max_x()) / 10) + 1) * 10
ymax = int((float(data.max_y()) / 10) + 1) * 10
print 'xmax:', xmax
print 'ymax:', ymax
plot(sliced_data.x, sliced_data.y, sliced_data.value, xmax, ymax)


